<link rel="stylesheet" href="__FORJS__/css/individual/sidebar.css"/>
<include file="./Application/Home/View/Common/backup/aside_combiner.html" />
<script type="text/javascript">
    //当前图文合并器里的图文id列表
    var news_all = new Array();
    var news_count=0;
    +function ($) {

        var _this = $('.sidebar');

        /*
        * 合并器
        */
        if ($('#frm_header #user_login').val() && $('.side_btn .merger', _this).length) {
            $.get('/combiner/get_art_ls', function(res) {
                news_count = res.total_number;
                if (res.data.length == 0) {
                    return;
                }
                $(".side_con > p").hide();
                var data = res.data;
                var content = '';
                for (var i = 0; i < res.total_number; i++) {
                    content += '<div data-articleID="' + data[i].cd + '">';
                    content += '<div class="comb-detail-title">' + data[i].title + '</div>';
                    content += '<img class="comb-detail-img" src="' + res.img_cdn + data[i].cover_img_url + '" onerror="this.src=\'/Public/static/images/wuyulantu.png\';"/>';
                    content += '<div class="comb-detail-filter">' +
                        '<button type="button" class="glyphicon glyphicon-eye-open" onclick="window.open(\'/article?p=' + data[i].cd + '\')"></button>' +
                        '<button type="button" class="glyphicon glyphicon-trash icon-delete" delete-event></button>' +
                        '</div>' +
                        '</div>';
                }
                $('.mer_num').html(news_count);
                $('.side_con').append(content);
            });
        }
        // 动态取得header高度
        var headerHeight = $('.header_container_main .top_main_nav').outerHeight();
        _this.css({
            top: headerHeight
        });
        $(window).scroll(function() {
            var top = headerHeight - $(this).scrollTop();
            top = top < 0 ? 0 : top;
            _this.css({top: top});
        });

        /*sildebar*/
        var side_show_isOk = true;
        _this.on('click', '.side_btn', function() {
            if (side_show_isOk) {
                _this.addClass('active');

                if ($.isFunction(window.bw_sidebar && window.bw_sidebar.show)) {
                    clearTimeout(_this.timeId);
                    _this.timeId = setTimeout(function(){
                        window.bw_sidebar.show.call(_this);
                    }, 700);
                }

                $('body').on('click', '.delete_confirm,.sidebar', function(e) {
                    e.stopPropagation();
                });
                $(document).one('click.sidebar', sidebarMoveOut);
                side_show_isOk = false;
            } else {
                sidebarMoveOut();
            }
            function sidebarMoveOut() {
                _this.removeClass('active');
                side_show_isOk = true;
                if ($.isFunction(window.bw_sidebar && window.bw_sidebar.hide)) {
                    clearTimeout(_this.timeId);
                    _this.timeId = setTimeout(function(){
                        window.bw_sidebar.hide.call(_this);
                    }, 700);
                }
            }
        });
        $('.art_date', _this).text(new Date().format('yyyy-MM-dd'));
    }(jQuery);
</script>